﻿using System.Windows;
using System.Windows.Controls;

namespace Alvin.Window.Utils.TouchView.UserContorl
{
    /// <summary>
    /// UCKeyboard.xaml 的交互逻辑
    /// </summary>
    public partial class UCKeyboard : UserControl
    {
        public static bool shiftKeyDown = false;
        public UCKeyboard()
        {
            InitializeComponent();
        }

        private void Key_Click(object sender, RoutedEventArgs e)
        {
            string name = ((System.Windows.FrameworkElement)(sender)).Name;
            if (shiftKeyDown)
            {
                KeyboardSend.PushTeamKeys(this.VK_SHIFT.Name, name);
                this.ChangedToSymbols(false);
                shiftKeyDown = false;
                this.VK_SHIFT.Opacity = 1;
            }
            else
            {
                KeyboardSend.PushKey(name);
                if (name.Equals(this.VK_SHIFT.Name))
                {
                    this.ChangedToSymbols(true);
                    shiftKeyDown = true;
                    this.VK_SHIFT.Opacity = 0.4;
                }
            }
        }

        /// <summary>
        /// 切换至符号键盘
        /// </summary>
        private void ChangedToSymbols(bool isChange)
        {
            if (isChange)
            {
                this.Key_1.Content = "!";
                this.Key_2.Content = "@";
                this.Key_3.Content = "#";
                this.Key_4.Content = "$";
                this.Key_5.Content = "%";
                this.Key_6.Content = "^";
                this.Key_7.Content = "&";
                this.Key_8.Content = "*";
                this.Key_9.Content = "(";
                this.Key_0.Content = ")";
            }
            else
            {
                this.Key_1.Content = new TextBlock { Text = "1" };
                this.Key_2.Content = new TextBlock { Text = "2" };
                this.Key_3.Content = new TextBlock { Text = "3" };
                this.Key_4.Content = new TextBlock { Text = "4" };
                this.Key_5.Content = new TextBlock { Text = "5" };
                this.Key_6.Content = new TextBlock { Text = "6" };
                this.Key_7.Content = new TextBlock { Text = "7" };
                this.Key_8.Content = new TextBlock { Text = "8" };
                this.Key_9.Content = new TextBlock { Text = "9" };
                this.Key_0.Content = new TextBlock { Text = "0" };
            }
        }
    }
}
